import 'package:elevator/get/intl_keys.dart';
import 'package:elevator/pages/login/login_view.dart';
import 'package:elevator/utils/utils_dialog.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../storage/local_storage.dart';
import '../../../utils/utils_logger.dart';
import '../../../widgets/globel_widget.dart';
import '../../../widgets/spirit/spirit_view.dart';
import 'page_mine_logic.dart';

class MinePage extends StatelessWidget {
  final logic = Get.put(Page_mineLogic());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        flexibleSpace: const SafeArea(
          child: Text(''),
        ),
        centerTitle: true,
        title: Text(IntlKeys.signStatus.tr),
      ),
      body: Column(
        children: [
          Center(
            child: Container(
              margin: const EdgeInsets.all(15),
                child: const Text('HUANG HAO B01 \nTEL:138012345678', style: TextStyle(fontSize: 18),)),
          ),
          spaceHeight(),
          Container(
            height: 60,
            margin: const EdgeInsets.symmetric(horizontal: 12),
            child: GestureDetector(
              onTap: () {
                Get.defaultDialog(title:IntlKeys.changeLanguage.tr, content: Column(
                  mainAxisSize: MainAxisSize.min,

                  children: [
                    TextButton(onPressed: () {
                      Get.back();
                      change2CHLocal();
                    } , child: Text('简体中文')),
                    TextButton(onPressed: () {
                      Get.back();
                      changeUSLocal();
                    }, child: Text('English')),
                  ],
                ),);
              },
              child: Row(
                children: [
                   Text('languageLabel'.tr),
                  spaceWidth(),
                  Text('language'.tr)
                ],
              ),
            ),
          ),
          // spaceHeight(),
          // line(),
          // Container(
          //   height: 60,
          //   margin: const EdgeInsets.symmetric(horizontal: 12),
          //   child: Row(
          //     children: [
          //       const Text('菜单语言'),
          //       spaceWidth(),
          //       const Text('Englis')
          //     ],
          //   ),
          // ),
          spaceHeight(),
          line(),
          Container(
            height: 80,
            margin: const EdgeInsets.symmetric(horizontal: 12),
            child: Row(
              children: [
                Text('groupName'.tr),
                spaceWidth(),
                const Text('''
                Group1：1834-MS//
                Group5:1834-ABC
                Group2：1834-ISC//..''')
              ],
            ),
          ),
          spaceHeight(),
          line(),
          Container(
            height: 50,
            margin: const EdgeInsets.symmetric(horizontal: 12),
            child: Row(
              children: [
                Text('version'.tr),
                spaceWidth(),
                const Text('V0.0.1')
              ],
            ),
          ),
          spaceHeight(),
          line(),
          spaceHeight(height: 30),
          SizedBox(width : 200, child: ElevatedButton(onPressed: () {
            UtilsDialog.showSingleNoticeDialog(context, 'loginOut'.tr, onPressed: () {
              Navigator.pop(context);
              Get.off(const LoginPage());
            });
            // Get.off(LoginPage());
          }, child: Text('logout'.tr)))
        ],
      ),
    );
  }


  Widget line() {
    return Container(
      height: 0.5,
      color: Colors.grey,
      width: Get.width,
    );
  }

  void changeUSLocal() {
    var locale = const Locale('en', 'US');
    Get.updateLocale(locale);
    LocalStorage.setString('local', 'en');
  }

  void change2CHLocal() {
    var locale = const Locale('zh', 'CH');
    Get.updateLocale(locale);
    LocalStorage.setString('local', 'zh');
  }
}
